<template>
	<view class="bg-white">
		<cu-custom @handLeft='handLeft' bgColor="bg-black" :isBack="true">
			<block slot="content">律师详情</block>
		</cu-custom>
		<view class="lawyer-details-box">
			<view class="lawyer-top">
				<view class="law-left">
					<view class="left-item">
						<view @click="cancle()" v-if="showS" class="item-icon cuIcon-favorfill text-yellow text-xs">

						</view>
						<view @click="follow()" v-if="!showS"  class="item-icon cuIcon-favor text-yellow text-xs">
						
						</view>
						<view class="item-title text-yellow">
							关注
						</view>
					</view>
					<view class="left-item" @click="handChat">
						<view class="item-icon cuIcon-commentfill text-yellow">

						</view>
						<view class="item-title text-yellow" >
							咨询
						</view>
					</view>
					<view class="left-item">
						<view class="item-icon cuIcon-rechargefill text-yellow">

						</view>
						<view class="item-title text-yellow">
							律师费
						</view>
					</view>
					<view class="left-item">
						<view class="item-icon cuIcon-forward text-yellow">

						</view>
						<view class="item-title text-yellow">
							分享
						</view>
					</view>
				</view>
				<view class="bg-img law-right" :style="{backgroundImage:'url('+ lawDetails.handUrl +')'}">
					<view class="bg-shadeBottom padding padding-bottom-xl law-right-txt">
						<view class="name">
							{{lawDetails.lawyerName}}
						</view>
						<view class="name-num">
							执业{{lawDetails.practiceYear}}年
						</view>
						<view class="text-cut">
							<view class="cu-tag line-blue round" v-for="ele in lawDetails.goodAt">
								{{ele}}
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
		<view class="cu-list menu-avatar comment solids-top">
			<view class="cu-item">
				<view class="cu-avatar round cuIcon-edit bg-yellow text-white"></view>
				<view class="content">
					<view class="text-grey">
						<view class="item_name">
							律师简介
						</view>
					</view>
					<!-- <view class="text-gray text-content text-df">
							艾欧尼亚
						</view> -->
					<view class="radius margin-top-sm  text-sm">
						<view class="flex">
							<view class="flex-sub">{{lawDetails.content}}</view>
						</view>
					</view>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				lawDetails: {},
				ids:'',
				showS:''
			};
		},
		async onLoad(e) {
			// userid
			this.ids = e.id
			// console.log(this.ids)
			// 律师详情
			this.lawDetails = await this.http.seeLawyerInfo({
				id: e.id
			})
			if(this.lawDetails.isFollow == 0){
				this.showS = false
			}else if(this.lawDetails.isFollow == 1){
				this.showS = true
			}
			this.lawDetails.goodAt = this.lawDetails.goodAt.split(',')
			console.log(this.lawDetails,22222)
		},
		// async mounted(){
		// 	await this.LawyerInfo()
		// },
		methods:{
			// 资讯
			async handChat(){
				let res = await this.http.saveChatRoom({
					lawId: this.lawDetails.userId,
					isOpen: 1
				})
				console.log(res)
				uni.navigateTo({
					url:'/pages/message/myConsult/myConsult'
				})
				// uni.navigateTo({
				// 	url:'/pages/chat/chat'
				// })
			},
			// 律师详情
			// async LawyerInfo(){
			// 	let res = await this.http.seeLawyerInfo({
			// 		id:this.ids
			// 	})
			// 	if(res.isFollow == 0){
			// 		this.showS = false
			// 	}else if(res.isFollow == 1){
			// 		this.showS = true
			// 	}
			// 	console.log(res,11111111)
			// },
			//关注
			async follow(){
				let res = await this.http.followLawer({
					lawyerid:this.ids
				})
				console.log(res)
				if(res.code == 200){
					this.showS = true
					this.print('关注成功！')
				}
			},
			// 取消关注
			async cancle(){
				let res = await this.http.cancelfollow({
					lawid:this.ids
				})
				console.log(res)
				if(res.code == 200){
					this.showS = false
					this.print('取消关注成功！')
				}
			},
			
			
			
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff !important;
	}

	.lawyer-details-box {
		padding: 30upx;
		box-sizing: border-box;

		.lawyer-top {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.law-left {
				display: flex;
				width: 214upx;
				flex-direction: column;
				height: 784upx;
				justify-content: space-between;
				padding: 80upx 0;
				box-sizing: border-box;

				.item-icon {
					font-size: 40upx;
					margin-bottom: 10upx;
				}

				.left-item {

					text-align: center;
				}
			}

			.law-right {
				width: 536upx;
				height: 784upx;
				position: relative;
				border-radius: 10upx;

				.law-right-txt {
					width: 100%;
					position: absolute;
					bottom: 0;

					.name {
						color: #fff;
						font-size: 48upx;
						font-weight: bold;
						margin-bottom: 20upx;
					}

					.name-num {
						color: #fff;
						font-size: 28upx;
						margin-bottom: 20upx;
						position: relative;
						display: inline-block;
						&::before {
							content: '证';
							display: block;
							position: absolute;
							line-height: 36upx;
							text-align: center;
							color: #fff;
							width: 36upx;
							height: 36upx;
							border-radius: 50%;
							right: -50upx;
							top: 50%;
							margin-top: -18upx;
							font-size: 22upx;
							background: linear-gradient(180deg, rgba(252, 219, 0, 1) 0%, rgba(247, 181, 0, 1) 100%);
						}
					}

					.txts {
						// width:366upx;
						line-height: 40upx;
						padding-left: 16upx;
						height: 40upx;
						border-radius: 4upx;
						border: 1upx solid rgba(150, 151, 153, 1);
						color: #969799;
						font-size: 20upx;
					}
				}
			}
		}

	}
</style>
